<template>
    <div>
        this is list component <br>
        msg: {{ msg }} <br>
        <button @click="sendMsg">给父传数据</button>
        <p>来自Child组件的数据：{{ res }}</p>
    </div>
</template>

<script setup>
// 接收来自父组件的参数
// 数据只读
const props = defineProps({
    msg: {
        type: String,
        default: '666(default)'
    }
})


// 给父组件传数据
let childMsg = ref('子组件的数据')
const emit = defineEmits(['fn'])
let sendMsg = () => {
    emit('fn', childMsg)
}

import emitter from '../plugins/Bus'
let res = ref('')
onBeforeMount(() => {
    emitter.on('fn', e => {
        console.log(e);
        res.value = e.value
    })
})
</script>